#ifndef HEADER
#define HEADER

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <unistd.h>

#if defined(__linux__)

#include <time.h>
// #define getch() getchar()

#elif defined(__WIN32__)

#include <conio.h>
#include <curse.h>

#else

#endif

#define MAPSIZE 20
#define MAXX MAPSIZE + 10
#define COIN 10

#define cls clear

extern int coin, life, key, padlock, nowx, nowy, tot_steps, map[MAXX][MAXX];
extern char name[][10];
extern int color[];
extern int head, tail, queuex[MAXX * MAXX], queuey[MAXX * MAXX],
    record[MAXX][MAXX], path[MAXX * MAXX], p, bucket[11];
extern int movex[];
extern int movey[];
extern int movexx[128];
extern int moveyy[128];
extern int move_num[5];
extern int flag, needcls, visible[MAXX][MAXX], vis[MAXX][MAXX];

struct User {
  char name[100];
  double score;
  int coin, padlock, key;
  double time;
  int tot_step, life;
};
int max(int a, int b);

int min(int a, int b);

void mySleep(int);

int in_the_map(const int a, const int b);

int bfs(const int cur_x, const int cur_y, const int find_coin);

int my_rand(const int from, const int to);

void make_it_vis(int x, int y);

void init_card();

void setcolor(const int x);

void print_color(int num);

void display_card();

void judge(const int x, const int y);

void Move_character(const int num);

void move_character();
#ifdef __WIN32__

void full_screen();
void HideCursor();

#endif
#ifdef __linux__

char getch();

#endif
double f1(int x);

double f2(int x);

double f(int coin, int padlock, int key, double time, int tot_step, int life);

int cmp(struct User a, struct User b);

void output(struct User *tmp, int NO);

void insert_sort(struct User tmp);

void project();

void win();

void enter_the_game();

void show_rank();
#endif
